package com.hbsi.demo2;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/**
 * @author 程奕红
 * @version 1.0
 */
public class TestMyString {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        MyString myString=new MyString();
        System.out.println(myString);


        Class c1=myString.getClass();
        Field[] fields=c1.getDeclaredFields();
        for(Field field:fields){
            if(field.getType()==String.class){
                field.setAccessible(true);
                String val=(String)field.get(myString);
                       String newVal= val.replace('b','a');
                        field.set(myString,newVal);

            }


        }

        System.out.println(myString);
    }
    //通用的工具方法，可以对任意类型的对象中的String类型的属性就行修改
    public static void changeString(Object object){










    }
}
